import React, { Component } from 'react'
import { inject, observer } from 'mobx-react';
import { hashHistory } from 'react-router';
import { Toast, ListView, Picker, Flex, Button } from 'antd-mobile'
import { createForm } from 'rc-form';
import Top from 'components/top'
import Ajax from 'lib/Ajax'
import Msg from 'mixin/msg'

const pageName = 'teacherMsg';

@inject('appStore', 'languageStore')
@observer
class ModuleName extends Msg {
	constructor(props) {
    super(props);
		this.searchOption = {
			teacherId: this.props.params.id
		}
		this.msgApi = '/teacher/get';
  }

	addline = () => {
    Ajax({
      url: '/chat/addline',
      data: {
        "userId": this.props.appStore.userData.userId,
        "teacherId": this.props.params.id
      },
      success: function(result){
        hashHistory.push('/chat/' + result.chatLineId);
      },
      error: function(error){
        Toast.info(error||'请求失败');
        self.props.onClose();
      }
    });
  }

  render() {
    const pageData = this.props.languageStore.getPageData(pageName);
    const { coverImg, introduction, name, createTime, score, school, helpPeople, major, successRate, expertise } = this.state.msgData;
    const { imgBaseUrl } = this.props.appStore;
    return (
    	<div className={pageName}>
        <Top
          title={pageData.title}
        />
        <div className={`${pageName}-Content`}>
					<div className="teacher-temp">
						<div className="img-box">
							<img src={`${imgBaseUrl}${coverImg}`} alt="" className="coverImg" />
							<p className="name">{ name||"" }</p>
							<p className="zhiwei">{ major||"" }</p>
							<p className="helpPeople">已帮 <span>{helpPeople||0}</span> 位学生实现留学梦</p>
						</div>
						<div className="blank" style={{height: '.1rem'}}></div>
						<div className="clearfix">
							<span className="pf">
								<i>{score||0}</i> 分
							</span>
							<span className="fr">
								<i><em>{successRate||0}%</em> 申请成功</i>
								<Button type="primary" size="small" onClick={this.addline}>咨询TA</Button>
							</span>
						</div>
						<div className="blank" style={{height: '.2rem'}}></div>
						<div>
							<h3 className="title">导师介绍</h3>
							<div className="con" dangerouslySetInnerHTML={{__html: introduction}}></div>
							<div className="blank" style={{height: '.2rem'}}></div>
							<h3 className="title">导师擅长国家</h3>
							<div className="con">{expertise}</div>
						</div>
					</div>
        </div>
    	</div>
    )
  }
}

module.exports = ModuleName
